﻿@model Student // 声明视图模型的类型 （如果没有视图模型类型，标签助手就没啥意义了）
@{
    ViewBag.Title = "Title";
    Layout = "_Layout";
}
<style>
    .table span,.asp-validation-summary {
        color:red;
    }
</style>
<h2>表单标签助手</h2>
<form asp-action="Submit" asp-controller="Student" method="post">
    <!--标签助手，以asp开头，如果不指定控制器，默认提交到当前控制器的Action中-->
    <div asp-validation-summary="ModelOnly"></div>
    <table class="table">
        <tr>
            <td><label asp-for="Account"></label></td>
            <td>
                <input asp-for="Account" class="form-control"/>
            </td>
            <td>
                <!--错误提示，只能用span标签-->
                <span asp-validation-for="Account"></span>
            </td>
        </tr>
        <tr>
            <td><label asp-for="Pwd"></label></td>
            <td>
                <input asp-for="Pwd" class="form-control" />
            </td>
            <td>
                <!--错误提示，只能用span标签-->
                <span asp-validation-for="Pwd"></span>
            </td>
        </tr>
        <tr>
            <td><label asp-for="ConfirmPassword"></label></td>
            <td>
                <input asp-for="ConfirmPassword" class="form-control" />
            </td>
            <td>
                <!--错误提示，只能用span标签-->
                <span asp-validation-for="ConfirmPassword"></span>
            </td>
        </tr>
        <tr>
            <td><label asp-for="Hobby"></label></td>
            <td>
                <input asp-for="Hobby" class="form-control" />
            </td>
            <td>
                <!--错误提示，只能用span标签-->
                <span asp-validation-for="Hobby"></span>
            </td>
        </tr>
        <tr>
            <td><label asp-for="Hobby"></label></td>
            <td>
                <input type="checkbox" name="Hobby" value="爬山" /> 爬山
                <input type="checkbox" name="Hobby" value="编程"  /> 编程
                <input type="checkbox" name="Hobby" value="篮球"  /> 篮球
            </td>
        </tr>
        <tr>
            <td><label asp-for="Sex"></label></td>
            <td>
                <input type="radio" name="Sex" value="爬山"  /> 男
                <input type="radio" name="Sex" value="编程"  /> 女
            </td>
        </tr>
        <tr>
            <td><label asp-for="Province"></label></td>
            <td>
               <select asp-for="Province" asp-items="ViewBag.ProvinceList" class="form-control">
                   <option value="0">请选择</option>
               </select>
            </td>
            <td>
                <span asp-validation-for="Province"></span>
            </td>
        </tr>
        <tr>
            <td><label asp-for="Birthday"></label></td>
            <td>
                <input asp-for="Birthday" class="form-control" />
            </td>
            <td>
                <span asp-validation-for="Birthday"></span>
            </td>
        </tr>
        <tr>
            <td><label asp-for="Birthday"></label></td>
            <td>
                <textarea  asp-for="Birthday" class="form-control">
                </textarea>
            </td>
            <td>
                <span asp-validation-for="Birthday"></span>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <input type="submit" value="提交" class="btn btn-primary" />
            </td>
        </tr>
    </table>
</form>
@section Scripts
{
    <!--可在此处引入库，也可以在模板页中引入。-->
    @* <script src="~/lib/jquery/dist/jquery.js"></script> *@

    <!--引入部分视图,如果部分视图中引入了一些js库，那等于应用视图也和"部分视图"一样引入了-->
    <partial name="_ValidationScriptsPartial"/>
    @* <script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script> *@
    @* <script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script> *@
}